<?php
	@$UserID = $_COOKIE['studialuserid'];
	@$HomeID = $_POST['homeid'];
	@$Content = $_POST['topic'];
	@$Link = $_POST['link'];
	
	if ( !$UserID || !$HomeID || empty($Content) )
	{
		header("location: ../users/homeboard.php?id=".$HomeID);
	}
		
	@ $db = mysql_pconnect("localhost","root","");
		
	if(!$db)
	{
		echo "<h2>Database does not exist!</h2>";
		exit;
	}
		
	mysql_set_charset('UTF8');
	mysql_select_db('studial');
		
	$arr = getdate();
	$time = "$arr[year]-$arr[mon]-$arr[mday] $arr[hours]:$arr[minutes]:$arr[seconds]";
		
	$result = "INSERT INTO `topics` (`user_id`, `home_id`, `type`, `path`, `content`, `datecreated`, `numliked`, `numcommented`) VALUES ('".$UserID."', '".$HomeID."', 1, '".$Link."', '".$Content."', '".$time."', 0, 0)";
		
	$query = mysql_query($result) or die('Error, query failed');
	
	header("location: ../users/homeboard.php?id=".$HomeID);
?>